﻿using System.Collections.Generic;
using Entitas;
class EnemyResetRoamingTimerSystem : ReactiveSystem<EnemyEntity>
{
    public EnemyResetRoamingTimerSystem(Contexts contexts) : base(contexts.enemy)
    {
    }
protected override void Execute(List<EnemyEntity> entities)
    {
       foreach(var e in entities)
        {
            if (e.roamingTimer.value <= 0)
            {
                e.ReplaceRoamingTimer(1.5f);
               
            }
        }
    }

    protected override bool Filter(EnemyEntity entity)
    {
        return entity.isRoaming == true && entity.hasRoamingTimer;
    }

    protected override ICollector<EnemyEntity> GetTrigger(IContext<EnemyEntity> context)
    {
        return context.CreateCollector(EnemyMatcher.RoamingTimer.AddedOrRemoved());
    }
}